<template>
  <div >
      <view>
        <van-dialog id="van-dialog" />
        <van-toast id="van-toast" />

        <view style='width: 100%;  height: 1rpx' />
        <i-row class="header-row">
          <i-col span="8" i-class="col-class">
            <view class="table_parent">创建时间</view>
          </i-col>
          <i-col span="8" i-class="col-class">
            <view class="table_parent">删除时间</view>
          </i-col>
          <i-col span="8" i-class="col-class">
            <view class="table_parent">代理人</view>
          </i-col>
        </i-row>
        <view class="block-order" style='width: 100%;  height: 1rpx;' />
        <block   v-for="(item, index) in orderlist" :key="index" >
          <i-row class="row-order" @tap="goInfo(item._id)">
            <i-col span="8" i-class="col-class">
              <view class="table_parent">{{item.addtime}}</view>
            </i-col>
            <i-col span="8" i-class="col-class">
              <view class="table_parent">{{item.deltime}}</view>
            </i-col>
            <i-col span="8" i-class="col-class">
              <view class="table_parent">{{item.username}}</view>
            </i-col>
          </i-row>
        </block>
      </view>




  </div>
</template>

<script>

  import Notify from '../../../static/vant/notify/notify';
  import Dialog from '../../../static/vant/dialog/dialog';
  import Toast from  '../../../static/vant/toast/toast';
  import * as dayjs from 'dayjs'
  import 'dayjs/locale/zh-cn' // import locale

  import {orderListText} from '../../api/basisMG'


  export default {
  data () {
    return {
      addExpressshowBtn:true,
      addExpressshowSpan:0,
      spantools:8,
      isToolsShow:true,
      orderlist:[],
      chosenContactId: null,
      editingContact: {},
      showList: false,
      showEdit: false,
      isEdit: false,
      list: [],
      values:[],
      valuesAllid:[],
      valueAll:[],
      addExpressshow:false

    }
  },
  beforeMount(){
    wx.getUserInfo({
      success:(data)=>{
        console.log(data)
      }
    })
    },

  onShow() {
    this.isToolsShow = true
    this.rowdata(0)
  },


  methods: {

    rowdata(page){
      this.orderlist  = []
      let pagesize = 50
      orderListText({"page":page,"pagesize":pagesize,"query":{"deltime":{'$gt':300}}}).then(res => {
          if(res.pages){
            this.orderlist = res.data
          }
          // if(res.pages<pagesize){
          //   this.showNext = true
          // }else{
          //   this.showPerv = false
          // }
          // if(page==0){
          //   this.showPerv = true
          // }
        }
      )
    },

    // rowdata(){
    //   let t = this
    //   wx.cloud.init({
    //     env: t.globalData.env
    //   })
    //
    //
    //
    //   wx.cloud.callFunction({
    //     name: 'manageOrder',
    //     data:{
    //       want:"dellist"
    //     },
    //     success(res) {
    //       let data = res.result.data;
    //       var newArr = data.map(function(item){
    //         item["addtime"] = dayjs(item["addtime"]*1000).format('MM-DD HH:mm:ss')
    //         item["deltime"] = dayjs(item["deltime"]*1000).format('MM-DD HH:mm:ss')
    //         return item
    //       })
    //       t.orderlist = newArr
    //     }
    //   })
    // },

    goInfo(d){
      if(!this.isToolsShow){
        this.toggle(d)
        return false
      }
      console.log(d)
      wx.navigateTo({
        url: "/pages/manageOrder_info/main?id="+d
      })

    },

    changeUsername(data){
      this.username = data.mp.detail
    },
    changepassword(data){
      this.password = data.mp.detail
    },
    getUserInfo(data){
      if(data.mp.detail.rawData){
        wx.getUserInfo({
          success:(data)=>{
            console.log(data)
            this.userInfo = data.userInfo
          }
        })
      }
    },
    bindViewTap () {
      const url = '../logs/main'
      if (mpvuePlatform === 'wx') {
        mpvue.switchTab({ url })
      } else {
        mpvue.navigateTo({ url })
      }
    },
    clickHandle (ev) {
      console.log('clickHandle:', ev)
      // throw {message: 'custom test'}
    }
  }
}
</script>

<style >
  ._van-field{
    background: red;
  }

  .cbox .van-col{
    margin:28rpx;
  }

  .tooslbtns .van-button--small{
    margin: 0 11rpx;
  }

  .block-order{
    margin-top: 95rpx;
  }

  .header-row{
    position: fixed;
    width: 100%;
    line-height: 2;
    margin-top: -1rpx;
    border-bottom: 1rpx solid #ccc;
  }


  .row-order{
    line-height: 2;
  }

  .row-order .van-row{
    border-bottom: 1rpx solid #eee;
  }

  page {
    background-color: #fff;
  }

  .table_parent {
    display:flex;
    justify-content:center;
    align-items:center;
    background: white;
    font-size:30rpx;
    text-align:center;
    box-sizing:border-box;
    color:#595a5e;
    padding-top: 20rpx;
    padding-bottom: 20rpx;
  }
  .table {
    border: 1px solid #dadada;
    border-right: 0;
    border-bottom: 0;
    width: 98%;
  }

  .tr {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  .th, .td {
    padding: 10px;
    border-bottom: 1px solid #dadada;
    border-right: 1px solid #dadada;
    text-align: center;
    width: 100%;
  }

  .th {
    font-weight: 400;
    background-color: #dadada;
  }

</style>
